package inbound.receiving.dataObjects
{
	import mx.collections.ArrayCollection;

	[Bindable]
	public class ReceiptContainerDO
	{
		public var INTERNAL_CONTAINER_NUM:Number = 0;
		public var INTERNAL_RECEIPT_NUM:Number = 0;
		public var INTERNAL_RECEIPT_LINE_NUM:Number = 0;
		public var RECEIPT_ID:String = "";
		public var RECEIPT_TYPE:String = "";
		public var CONTAINER_ID:String = "";
		public var CONTAINER_TYPE:String = "";
		public var PARENT:Number = 0;
		public var COMPANY:String = "";
		public var ITEM:String = "";
		public var ITEM_DESC:String = "";
		public var ITEM_CLASS:String = "";
		public var QUANTITY:Number = 0;
		public var QUANTITY_UM:String = "";
		public var STATUS:Number = 200;
		public var WAREHOUSE:String = "";
		public var LOCATING_RULE:String = "";
		public var FROM_LOCATION:String = "";
		public var TO_LOCATION:String = "";
		public var DATE_TIME_STAMP:Date = new Date();
		public var ATTRIBUTE_NUM:Number = 0;
		public var ATTRIBUTE1:String = "";
		public var ATTRIBUTE2:String = "";
		public var ATTRIBUTE3:String = "";
		public var ATTRIBUTE4:String = "";
		public var ATTRIBUTE5:String = "";
		public var ATTRIBUTE6:String = "";
		public var ATTRIBUTE7:String = "";
		public var ATTRIBUTE8:String = "";
		public var INVENTORY_STS:String = "";
		public var USER_STAMP:String = "";
		public var TASK_CREATED:String = "";
		
		public function ReceiptContainerDO()
		{
		}
		
		public function Init(xmlObj:XML):void{			
			if(null == xmlObj)
				return;
			else{
				for each (var itemProp:XML in xmlObj.children()) {
					//Use XML node name to reference matching property in value object				
					this[itemProp.name()] = itemProp;
				}
			}
		}
		public function ToXML():XML{
			var xmlObj:XML = 
				<RECEIPT_CONTAINER xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
					<INTERNAL_CONTAINER_NUM>{INTERNAL_CONTAINER_NUM}</INTERNAL_CONTAINER_NUM>
					<INTERNAL_RECEIPT_NUM>{INTERNAL_RECEIPT_NUM}</INTERNAL_RECEIPT_NUM>
					<INTERNAL_RECEIPT_LINE_NUM>{INTERNAL_RECEIPT_LINE_NUM}</INTERNAL_RECEIPT_LINE_NUM>
					<RECEIPT_ID>{RECEIPT_ID}</RECEIPT_ID>
					<RECEIPT_TYPE>{RECEIPT_TYPE}</RECEIPT_TYPE>
					<CONTAINER_ID>{CONTAINER_ID}</CONTAINER_ID>
					<CONTAINER_TYPE>{CONTAINER_TYPE}</CONTAINER_TYPE>
					<PARENT>{PARENT}</PARENT>
					<COMPANY>{COMPANY}</COMPANY>
					<ITEM>{ITEM}</ITEM>
					<ITEM_DESC>{ITEM_DESC}</ITEM_DESC>
					<ITEM_CLASS>{ITEM_CLASS}</ITEM_CLASS>
					<QUANTITY>{QUANTITY}</QUANTITY>
					<QUANTITY_UM>{QUANTITY_UM}</QUANTITY_UM>
					<STATUS>{STATUS}</STATUS>
					<WAREHOUSE>{WAREHOUSE}</WAREHOUSE>
					<LOCATING_RULE>{LOCATING_RULE}</LOCATING_RULE>
					<FROM_LOCATION>{FROM_LOCATION}</FROM_LOCATION>
					<TO_LOCATION>{TO_LOCATION}</TO_LOCATION>
					<DATE_TIME_STAMP>{DATE_TIME_STAMP}</DATE_TIME_STAMP>
					<ATTRIBUTE_NUM>{ATTRIBUTE_NUM}</ATTRIBUTE_NUM>
					<ATTRIBUTE1>{ATTRIBUTE1}</ATTRIBUTE1>
					<ATTRIBUTE2>{ATTRIBUTE2}</ATTRIBUTE2>
					<ATTRIBUTE3>{ATTRIBUTE3}</ATTRIBUTE3>
					<ATTRIBUTE4>{ATTRIBUTE4}</ATTRIBUTE4>
					<ATTRIBUTE5>{ATTRIBUTE5}</ATTRIBUTE5>
					<ATTRIBUTE6>{ATTRIBUTE6}</ATTRIBUTE6>
					<ATTRIBUTE7>{ATTRIBUTE7}</ATTRIBUTE7>
					<ATTRIBUTE8>{ATTRIBUTE8}</ATTRIBUTE8>
					<INVENTORY_STS>{INVENTORY_STS}</INVENTORY_STS>
					<USER_STAMP>{USER_STAMP}</USER_STAMP>
					<TASK_CREATED>{TASK_CREATED}</TASK_CREATED>
				</RECEIPT_CONTAINER>;
			return xmlObj;
		}
				
		public static function getReceiptContainers(list:XMLList):ArrayCollection
		{
			var ac:ArrayCollection = new ArrayCollection();
			for each(var xml:XML in list)
			{
				var rcpCntDO:ReceiptContainerDO = new ReceiptContainerDO();
				rcpCntDO.Init(xml);
				ac.addItem(rcpCntDO);
			}
			return ac;
		}
	}
}